package com.swf.seed.xls.sheet;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

public class SheetUtils {
	public static HSSFWorkbook createHSSFWorkbook(){
		HSSFWorkbook wb = new HSSFWorkbook();  
		return wb;
	}
	
	public static HSSFSheet createHSSFSheet(String sheetName,HSSFWorkbook workbook) {
		HSSFSheet sheet = workbook.createSheet(sheetName);
		sheet.setColumnWidth(0, 4000);  
	    sheet.setColumnWidth(1, 3500);  
	 // 创建字体样式  
	    HSSFFont font = workbook.createFont();  
	    font.setFontName("Verdana");  
	    font.setBoldweight((short) 100);  
	    font.setFontHeight((short) 300);  
	    font.setColor(HSSFColor.BLUE.index);  
	    
	    // 创建单元格样式  
	    HSSFCellStyle style = workbook.createCellStyle();  
	    style.setAlignment(HSSFCellStyle.ALIGN_CENTER);  
	    style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);  
	    style.setFillForegroundColor(HSSFColor.LIGHT_TURQUOISE.index);  
	    style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);  
	    
	 // 设置边框  
	    style.setBottomBorderColor(HSSFColor.RED.index);  
	    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);  
	    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);  
	    style.setBorderRight(HSSFCellStyle.BORDER_THIN);  
	    style.setBorderTop(HSSFCellStyle.BORDER_THIN);  
	    
	    style.setFont(font);// 设置字体 
	    return sheet;
	}
}
